package com.controller;


import com.alibaba.fastjson.JSONObject;
import com.common.utils.Result;
import com.entity.TaskRecord;
import com.service.TaskRecordService;
import com.vo.FlowVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wty
 * @since 2022-01-06
 */
@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
@RestController
@RequestMapping("/taskRecord")
public class TaskRecordController {

    @Autowired
    private TaskRecordService taskRecordService;


    /**
     * 添加，修改记录
     */
    @RequestMapping("/updateTaskRecord")
    public Result updateTaskRecord(@RequestBody TaskRecord taskRecord ){
      return   taskRecordService.updateTaskRecord(taskRecord);
    }

    /**
     * 添加，修改记录
     */
    @RequestMapping("/updateRecord")
    public Result updateRecord(@RequestBody TaskRecord taskRecord ){
        boolean flag = taskRecordService.updateById(taskRecord);
        return flag?Result.success():Result.error("更新失败");
    }


    /**
     * 查询所有node
     */
    @RequestMapping("/getTaskList")
    public  Result getTaskList(){
        return  taskRecordService.getTaskList();

    }

    @RequestMapping("/flow")
    public  String flow(@RequestBody FlowVo flowVo, HttpServletRequest request){
        System.out.println("request.getRequestURL() = " + request.getRequestURL());
        System.out.println("JSONObject.toJSONString(flowVo) = " + JSONObject.toJSONString(flowVo));

        return taskRecordService.flow(flowVo);
//
//        for (String s : request.getParameterMap().keySet()) {
//            System.out.println("s = " + s);
//            System.out.println("request.getParameter(s) = " + request.getParameter(s));
//        }
//        System.out.println("----");
//        if(null!=flowVo){
//            System.out.println("JSONObject.toJSONString(flowVo) = " + JSONObject.toJSONString(flowVo));
//        }
//        return  "{}";
    }

    //抓取网站上的类容，然后整理出来，用小号发布

}

